# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=tree-sitter-typescript
pkgver=0.23.0
pkgrel=0
pkgdesc="TypeScript grammar for tree-sitter"
url="https://github.com/tree-sitter/tree-sitter-typescript"
arch="all"
license="MIT"
makedepends="tree-sitter-dev"
provides="tree-sitter-tsx=$pkgver-r$pkgrel"
install_if="tree-sitter-grammars"
source="https://github.com/tree-sitter/tree-sitter-typescript/archive/v$pkgver/tree-sitter-typescript-$pkgver.tar.gz"
options="!check"  # no tests for shared lib

_langs='tsx typescript'

build() {
	local lang; for lang in $_langs; do
		abuild-tree-sitter build -s "$lang/src"
	done
}

package() {
	local querydir="$pkgdir/usr/share/tree-sitter/queries"

	local lang; for lang in $_langs; do
		DESTDIR="$pkgdir" abuild-tree-sitter install -s "$lang/src"
	done

	rm "$querydir"/tsx/*
	echo '; inherits: typescript' > "$querydir"/tsx/highlights.scm
	echo '; inherits: typescript' > "$querydir"/tsx/injections.scm
}

sha512sums="
5ce5c7cf70c40027ac957a47756896fbdc3936593471d959459860a750fe8d47877f4d8be21140edcd49d9daa4fe715af15545ace5dabf3d2b399d380172d37f  tree-sitter-typescript-0.23.0.tar.gz
"
